﻿<?php
ob_start();
ignore_user_abort(true);
date_default_timezone_set("Asia/Shanghai");
if(isset($_SERVER['HTTP_APPVERSION'])){
include "./saesiteinfo.php";
}else{
 if(!file_exists("./install/install.lock")){
header('location:./install');
exit;
 }else{
include "./siteinfo.php";
 }
}
include "./function.php";
//连接数据库
$localhost=mysql_connect($sqlhost,$sqluser,$sqlpass)or die("无法连接服务器");
mysql_select_db($sqldata,$localhost);
if (isset($_COOKIE["SHANIUUSER"]) && isset($_COOKIE["SHANIUPASS"])){
$user=$_COOKIE["SHANIUUSER"];
$pass=$_COOKIE["SHANIUPASS"];
//获取用户资料
$mysql = mysql_query("SELECT * FROM user WHERE user='$user'");
$sql= mysql_fetch_array($mysql);
//获取QQ数
$qqnumsql="SELECT COUNT(id) FROM qqlist WHERE myqq='$user' ";
$qqnumqqlist = mysql_fetch_array( mysql_query($qqnumsql) );
$qqnum=$qqnumqqlist[0];
//默认服务器
$fuwu=fw1;
//获取当前时间
$time=time();
$zt='no';
//QID生成
$qid=date("Ymd")."".rand(1000000000,9999999999)."".date("His");
//初始化挂Q
$qq=$_GET['qq'];
$pw=$_GET['pwd'];
$sid=$_GET['sid'];
$skey=$_GET['skey'];
$qqlistrow = mysql_query("SELECT * FROM qqlist WHERE qq='$qq' and myqq='$user'");
$qqlist=mysql_fetch_array($qqlistrow);
$ssqq=mysql_query("select * from qqlist where qq='$qq'"); 
$ssqqnum=mysql_num_rows($ssqq);
echo ' <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><link href="css/stylesheets.css" rel="stylesheet" type="text/css" />';
if($ssqqnum)
 {  
mysql_query("update qqlist set sid='$sid',skey='$skey',skeyzt=0 where qq='$qq'");
echo "{$qq}更新成功！";
 }
 else{
if(isset($_pass['pass'])){
echo "您还没有登录";
}else{

if($qqnum>=$sql['peie']+$chushi){
echo "系统提示:挂Q配额已满,请扩充";
}else{
$qqpassword = tesy_encrypt($pw);
mysql_query("INSERT INTO qqlist (myqq,fwq,qid,qq,pw,sid,skey,skeyzt,time) VALUES ('$user','$fuwu','$qid','$qq','$qqpassword','$sid','$skey',0,'$time')");
echo "挂Q记录添加成功,请刷新页面";
file_get_contents("http://ti.3g.qq.com/g/s?sid=" . $sid . "&r=" . $qq. "&aid=arelate&ac=42&tu=weibiantai&bid=h%23QQGenius%230%230%230%2316");
//开启在线状态
file_get_contents('http://q32.3g.qq.com/g/s?sid='.$sid.'&s=10&aid=chgStatus');
}
}

}}else{
//如果没登录就显示下面的
header("Location: ./tishi.php");
}
?>